package com.ruoyi.contract.service.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.ruoyi.contract.domain.Contract;
import com.ruoyi.contract.domain.contractVo.ContractAllPaymentVo;
import com.ruoyi.contract.domain.reminderVo.ContractReminderVo;
import com.ruoyi.contract.service.IContractService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.contract.mapper.ExpirationReminderMapper;
import com.ruoyi.contract.domain.ExpirationReminder;
import com.ruoyi.contract.service.IExpirationReminderService;

/**
 * 合同到期提醒Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-10-18
 */
@Service
public class ExpirationReminderServiceImpl implements IExpirationReminderService 
{
    @Autowired
    private ExpirationReminderMapper expirationReminderMapper;
    @Autowired
    private IContractService contractService;

    /**
     * 查询合同到期提醒
     * 
     * @param expirationReminderId 合同到期提醒主键
     * @return 合同到期提醒
     */
    @Override
    public ExpirationReminder selectExpirationReminderByExpirationReminderId(Long expirationReminderId)
    {
        return expirationReminderMapper.selectExpirationReminderByExpirationReminderId(expirationReminderId);
    }

    /**
     * 查询合同到期提醒列表
     * 
     * @param expirationReminder 合同到期提醒
     * @return 合同到期提醒
     */
    @Override
    public List<ContractReminderVo> selectExpirationReminderList(ExpirationReminder expirationReminder)
    {
        List<ContractReminderVo> contractReminderVoList = expirationReminderMapper.
                selectExpirationReminderList(expirationReminder);
        for (ContractReminderVo contractReminderVo : contractReminderVoList) {
            // 获取签约方名称字符串，该字符串以英文逗号分隔
            String contractPartyName = contractReminderVo.getContractPartyName();
            // 将字符串按英文逗号分隔成数组
            String[] partyNames = contractPartyName.split(",");
            // 将数组转换为列表
            List<String> partyNameList = Arrays.asList(partyNames);
            contractReminderVo.setContractPartyList(partyNameList);
        }
        return contractReminderVoList;
    }

    /**
     * 新增合同到期提醒
     * 
     * @param expirationReminder 合同到期提醒
     * @return 结果
     */
    @Override
    public int insertExpirationReminder(ExpirationReminder expirationReminder)
    {
        return expirationReminderMapper.insertExpirationReminder(expirationReminder);
    }

    /**
     * 修改合同到期提醒
     * 
     * @param expirationReminder 合同到期提醒
     * @return 结果
     */
    @Override
    public int updateExpirationReminder(ExpirationReminder expirationReminder)
    {
        return expirationReminderMapper.updateExpirationReminder(expirationReminder);
    }

    /**
     * 批量删除合同到期提醒
     * 
     * @param expirationReminderIds 需要删除的合同到期提醒主键
     * @return 结果
     */
    @Override
    public int deleteExpirationReminderByExpirationReminderIds(Long[] expirationReminderIds)
    {
        return expirationReminderMapper.deleteExpirationReminderByExpirationReminderIds(expirationReminderIds);
    }

    /**
     * 删除合同到期提醒信息
     * 
     * @param expirationReminderId 合同到期提醒主键
     * @return 结果
     */
    @Override
    public int deleteExpirationReminderByExpirationReminderId(Long expirationReminderId)
    {
        return expirationReminderMapper.deleteExpirationReminderByExpirationReminderId(expirationReminderId);
    }
}
